package com.leiyuee.flink.tools.enums;

import com.alibaba.fastjson.JSONObject;
import com.leiyuee.flink.tools.enums.config.ConvertFunction;
import org.apache.flink.table.data.RowData;


import java.util.function.Function;

public enum RowDataFuncEnums {

   KAFKA_KMRECORD_TO_DORIS_ATTENDANCERECORDRT("KafkaKmRecord2DorisAttendanceRecordRT", ConvertFunction.KAFKA_KMRECORD_TO_DORIS_ATTENDANCERECORDRT),
    IOT_LINKER("Iotlinker", ConvertFunction.IOT_LINKER),
    KAFKA2DORIS_HR_SECURITY_VISITOR_REGISTRATION("Kafka2Doris_HR_Security_visitor_registration", ConvertFunction.KAFKA2DORIS_HR_SECURITY_VISITOR_REGISTRATION);
    private String id;
    private Function<JSONObject, RowData> function;

    RowDataFuncEnums(String id, Function<JSONObject, RowData> function) {
        this.id = id;
        this.function = function;
    }

    public String getId() {
        return id;
    }

    public Function<JSONObject, RowData> getFunction() {
        return function;
    }

    public static Function<JSONObject, RowData> getFuncById(String id) {

        for (RowDataFuncEnums rowDataFuncEnums : RowDataFuncEnums.values()) {
            if (rowDataFuncEnums.getId().equals(id)) {
                return rowDataFuncEnums.getFunction();
            }
        }
        return null;
    }
}